package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.TSingleselchoice;
import com.ruoyi.project.system.service.ITSingleselchoiceService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 单选选项Controller
 * 
 * @author ruoyi
 * @date 2020-05-14
 */
@RestController
@RequestMapping("/system/singleselchoice")
public class TSingleselchoiceController extends BaseController
{
    @Autowired
    private ITSingleselchoiceService tSingleselchoiceService;

    /**
     * 查询单选选项列表
     */
    @PreAuthorize("@ss.hasPermi('system:singleselchoice:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSingleselchoice tSingleselchoice)
    {
        startPage();
        List<TSingleselchoice> list = tSingleselchoiceService.selectTSingleselchoiceList(tSingleselchoice);
        return getDataTable(list);
    }

    /**
     * 导出单选选项列表
     */
    @PreAuthorize("@ss.hasPermi('system:singleselchoice:export')")
    @Log(title = "单选选项", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TSingleselchoice tSingleselchoice)
    {
        List<TSingleselchoice> list = tSingleselchoiceService.selectTSingleselchoiceList(tSingleselchoice);
        ExcelUtil<TSingleselchoice> util = new ExcelUtil<TSingleselchoice>(TSingleselchoice.class);
        return util.exportExcel(list, "singleselchoice");
    }

    /**
     * 获取单选选项详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:singleselchoice:query')")
    @GetMapping(value = "/{choiceId}")
    public AjaxResult getInfo(@PathVariable("choiceId") Integer choiceId)
    {
        return AjaxResult.success(tSingleselchoiceService.selectTSingleselchoiceById(choiceId));
    }

    /**
     * 新增单选选项
     */
    @PreAuthorize("@ss.hasPermi('system:singleselchoice:add')")
    @Log(title = "单选选项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSingleselchoice tSingleselchoice)
    {
        return toAjax(tSingleselchoiceService.insertTSingleselchoice(tSingleselchoice));
    }

    /**
     * 修改单选选项
     */
    @PreAuthorize("@ss.hasPermi('system:singleselchoice:edit')")
    @Log(title = "单选选项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSingleselchoice tSingleselchoice)
    {
        return toAjax(tSingleselchoiceService.updateTSingleselchoice(tSingleselchoice));
    }

    /**
     * 删除单选选项
     */
    @PreAuthorize("@ss.hasPermi('system:singleselchoice:remove')")
    @Log(title = "单选选项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{choiceIds}")
    public AjaxResult remove(@PathVariable Integer[] choiceIds)
    {
        return toAjax(tSingleselchoiceService.deleteTSingleselchoiceByIds(choiceIds));
    }
}
